﻿public class Solution {
    public bool LemonadeChange(int[] bills)
    {
        Dictionary<int, int> coinDic = new Dictionary<int, int>
        {
            [5] = 0,
            [10] = 0
        };

        for (int i = 0; i < bills.Length; i++)
        {
            if (bills[i] == 5)
            {
                coinDic[5]++;
            }
            else if (bills[i] == 10)
            {
                coinDic[10]++;
                coinDic[5]--;
            }
            else
            {
                if (coinDic[10] > 0)
                {
                    coinDic[10]--;
                    coinDic[5]--;
                }
                else
                {
                    coinDic[5] -= 3;
                }
            }

            if (coinDic[5] < 0) return false;
        }

        return true;
    }

    public static void Main(string[] args)
    {
        int[] bills = [5, 5, 5, 10, 20];
        Solution solution = new Solution();
        bool res = solution.LemonadeChange(bills);
        Console.WriteLine(res);
    }
}